(function(win){
	var $ = win.$;	
	
	var pages;
	
	$.ajax({
		url:"../../getvendorapplybypage?uid=1&startIndex=0&filter=1",
		dataType:"json",
		success:function(data){
			var q=[]
			for(i=0;i<data.length;i++){
				var color;
				if(data[i]["status"]==1){
					color="<span class='red'>未审核<span>";
				}else if(data[i]["status"]==2){
					color="<span class='blue'>审核未通过<span>";
				}else if(data[i]["status"]==3){
					color="<span class='green'>审核通过<span>";
				}
				q.push("<tr><td align='center' width='150'>"+data[i].title+"</td>");
				q.push("<td align='center' width='110'>"+data[i].arise_time+"</td>");
				q.push("<td align='center' width='130'>"+color+"</td></tr>");
			}
			$("#container").append(q.join(""));
		}
	})
	$("#search").change(function(){
		var sel=$(this).val();
		$.ajax({
			url:"../../getvendorapplybypage?uid=1&startIndex=0&filter="+sel,
			dataType:"json",
			success:function(data){
				$("#container").empty();
				var q=[];
				for(i=0;i<data.length;i++){
					var color;
					if(data[i].status==1){
						color="<span class='red'>未审核<span>";
					}else if(data[i].status==2){
						color="<span class='blue'>审核未通过<span>";
					}else if(data[i].status==3){
						color="<span class='green'>审核通过<span>";
					}
					q.push("<tr><td align='center' width='150'>"+data[i].title+"</td>");
					q.push("<td align='center' width='110'>"+data[i].arise_time+"</td>");
					q.push("<td align='center' width='130'>"+color+"</td></tr>");
				}
				$("#container").append(q.join(""));
			}
		})
	})
	
	 /*init pager*/
    $("#js-pagerWraper").pag({pageNumber : 1, displayNumber : 7, pageCount : 15 ,callback:function(num){
    	var n=((new Number(num))-1)*5;
		$.ajax({
			url:"../../getvendorapplybypage?uid=1&startIndex="+n+"&filter="+$("#search").val(),
			dataType:"json",
			success:function(data){
				$("#container").empty();
				var q=[];
				for(i=0;i<data.length;i++){
					var color;
					if(data[i].status==1){
						color="<span class='red'>未审核<span>";
					}else if(data[i].status==2){
						color="<span class='blue'>审核未通过<span>";
					}else if(data[i].status==3){
						color="<span class='green'>审核通过<span>";
					}
					q.push("<tr><td align='center' width='150'>"+data[i].title+"</td>");
					q.push("<td align='center' width='110'>"+data[i].arise_time+"</td>");
					q.push("<td align='center' width='130'>"+color+"</td></tr>");
				}
				$("#container").append(q.join(""));
			}
		})
    } });
    $('.button').click(function(){
        var height= $(parent.document.body).height(),width=$(parent.document.body).width();
        $(parent.document).find('.layout').css({
            'backgroundColor':'#eee',
            'height'     :   height,
            opacity      : 0.4
        }).show();
        var target=$(parent.document).find('div.dialog');
        target.css({
            left  :  (width-500)/2,
            top   :  (height-400)/2
        }).show();
    })
    
})(window)